// Include Files
#include "Vector.h"

/////////////////////////////////////////////////////////////////////////////////////
// vector_t Definitions

IE::vector_t IE::VectorDot( vector_t _lhs, vector_t _rhs )
{
	vector_t v0 = _mm_mul_ps(_lhs, _rhs);
	vector_t v1 = _mm_shuffle_ps(v0, v0, _MM_SHUFFLE(1, 0, 3, 2));
	vector_t v2 = _mm_add_ps(v0, v1);
	vector_t v3 = _mm_shuffle_ps(v2, v2, _MM_SHUFFLE(2, 3, 0, 1));
	return _mm_add_ps(v3, v2);
}

IE::vector_t IE::VectorCross( vector_t _lhs, vector_t _rhs )
{
	(void)_lhs; (void)_rhs;
	// TODO
	return _lhs;
}

IE::vector_t IE::VectorNorm( vector_t _lhs )
{
	vector_t v0 = _mm_mul_ps(_lhs, _lhs);
	vector_t v1 = _mm_shuffle_ps(v0, v0, _MM_SHUFFLE(1, 0, 3, 2));
	vector_t v2 = _mm_add_ps(v0, v1);
	vector_t v3 = _mm_shuffle_ps(v2, v2, _MM_SHUFFLE(2, 3, 0, 1));
	vector_t v4 = _mm_add_ps(v3, v2);
	vector_t v5 = _mm_sqrt_ps(v4);
	return _mm_div_ps(_lhs, v5);
}
